/**
*   \file   spherepoint.h
*   \author Dave Reid
*   \brief  Header file for checking if a point is contained inside or on the surface
*           of a Sphere.
*/
#ifndef __EAGL_INTERSECT_SPHEREPOINT_H_
#define __EAGL_INTERSECT_SPHEREPOINT_H_

#include "../types.h"

namespace eagl
{

/**
*   \brief                     Determines if a Sphere and point are intersecting.
*   \param  spherePos     [in] The position of the Sphere.
*   \param  radiusSquared [in] The squared radius of the Sphere.
*   \param  point         [in] The position of the point.
*   \return                    True if the point is inside the Sphere.
*/
inline bool intersect_spherepointsq(float radiusSquared, const vec3 &spherePos, const vec3 &point)
{
    vec3 d(spherePos - point);

    return (glm::dot(d, d) <= radiusSquared);
}

/**
*   \brief                 Determines if a Sphere and point are intersecting.
*   \param  spherePos [in] The position of the Sphere.
*   \param  radius    [in] The radius of the Sphere.
*   \param  point     [in] The position of the point.
*   \return                True if the point is inside the Sphere.
*/
inline bool intersect_spherepoint(float radius, const vec3 &spherePos, const vec3 &point)
{
    return intersect_spherepointsq(radius * radius, spherePos, point);
}



}


#endif  // __EAGL_INTERSECT_SPHEREPOINT_H_